//
//  DatabaseManager.h
//  iEasyBill
//
//  Created by student on 14-5-5.
//  Copyright (c) 2014年 com.yly16. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDatabase.h"
#import "iBill.h"
#import "iBillNote.h"
#import "iBillAccount.h"
#import "iBillAccountSub.h"
#import "iBillType.h"
#import "iBillTypeSub.h"
#import "User.h"

@interface DatabaseManager : NSObject
{
    FMDatabase *_database;
    iBillNote *_currentNote;
}
@property(strong,nonatomic)NSMutableArray *datalist;//装载bill信息可变数组
@property(strong,nonatomic)iBillNote *currentNote;
+(DatabaseManager*)shareManager;


-(instancetype)init;                           //初始化bill管理信息

-(NSString *)iBillFileDBPath;                  //找到数据库的路径


-(int)numberOfBills;                           //返回数据库的数据的数目，以供tableview显示

-(int)numberOfBillNotes;

-(BOOL)addNewBill:(iBill*)theBill;             //添加一个新的账单

-(BOOL)addNewBillNote:(iBillNote*)aNote;       //添加一个新的账本

-(BOOL)removeABillIndex:(iBill*)theBill;       //删除账单

-(BOOL)removeABillNoteIndex:(iBillNote*)aNote; //删除账本

-(BOOL)ModifyBill:(iBill*)theBill;             //编辑账单

-(BOOL)ModifyBillNote:(iBillNote*)aNote;        //编辑账本

-(NSMutableArray *)FindBill:(iBill*)theBill;    //查看账单

-(BOOL)addNewUser:(User*)user;
-(BOOL)ModifUser:(User*)user;
-(User*)showUser;

//显示最新的账单
-(NSMutableArray *)ShowUpToDateBillWithNumber:(int)number;
//显示指定日期得账单
-(NSMutableArray *)showBillByDate:(NSDate *)startDate toDate:(NSDate *)endDate toType:(iBillType*)type;

#pragma mark 账单消费类别
//TODO:>>>>>>>>>账单消费类别>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/*
 *@name:根据typeID显示账单类别
 */
-(iBillType*)showBillTypeByTypeID:(int)typeID;

/*
 *@name:显示所有的账单类别
 */
-(NSMutableArray *)showAllBillType:(BOOL)isPayOut;
/*
 *@name:添加新的账单类别
 */
-(BOOL)addNewBillType:(iBillType*)theType;

/*
 *@name:根据typeSubID显示账单子类别
 */
-(iBillTypeSub*)showBillSubTypeByTypeID:(int)typeSubID;
/*
 *@name:显示对应账单类别ID的账单子类别
 */
-(NSMutableArray *)showBillTypeSubById:(int)subId;
/*
 *@name:添加新的账单子类别
 */
-(BOOL)addNewBillTypeSub:(iBillTypeSub*)theTypeSub;
-(BOOL)removeABillType:(iBillType*)type;
-(BOOL)removeABillSubType:(iBillTypeSub*)subtype;
-(BOOL)ModifyBillTypeBudgetMoney:(id)type withMoney:(float)money;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>end>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//TODO:>>>>>>>>>账单账户>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/*
 *@name:显示所有的账户类型
 */
-(NSMutableArray *)showAllbillAccount;
/*
 *@name:添加新的账户类型
 */
-(BOOL)addNewBillAccount:(iBillAccount*)theAccount;
/*
 *@name:显示对应的账户ID的账户子类型
 */
-(NSMutableArray *)showAllbillAccountSubById:(int)subId;
/*
 *@name:添加新的账户子类别
 */
-(BOOL)addNewBillAccountSub:(iBillAccountSub*)theAccountSub;

-(iBillAccountSub *)showAAccountByBillAccountSubID:(int)accountSubID;

//TODO:日历
-(BOOL)jugeThedayIsHaveBill:(NSDate *)date;        //判断这天是否有Bill
//TODO:账本📒
//显示当前账本
-(iBillNote *)showCurrentlyByNoteName:(NSString*)name;
//显示账本
-(NSMutableArray *)ShowAllBillNote;

//>>>>>>>>>>>>>>
- (NSString *)getSettings;
- (void)setSettings;
//TODO:关闭数据库
- (BOOL)closeDataBase;
@end
